package com.santoker.user.service.config;

import com.santoker.baseservice.RequestLimitInterceptor;
import com.santoker.baseservice.util.IdWorker;
import org.dozer.DozerBeanMapper;
import org.dozer.Mapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class ServiceConfiguration implements WebMvcConfigurer {
	
	@Bean
    public IdWorker idWorkBean() {
        return new IdWorker(1, 1);
    }
	
	@Bean
    public Mapper mapperBena() {
        return new DozerBeanMapper();
    }

    @Bean
    public RequestLimitInterceptor requestLimitInterceptor() {
        return new RequestLimitInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(requestLimitInterceptor()).addPathPatterns("/**");
    }

}
